package com.chinasoft.goodsManager.dao.impl;

import com.chinasoft.goodsManager.dao.GoodsDao;
import com.chinasoft.goodsManager.domain.Journal;
import com.chinasoft.goodsManager.util.JDBCUtils;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class GoodsDaoImpl implements GoodsDao {

    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());

    @Override
    public List<Journal> Listjournal() {

        try {
            String sql = "select * from g_journal";
            List<Journal> query = template.query(sql, new BeanPropertyRowMapper<>(Journal.class));
            return query;
        } catch (DataAccessException e) {
            e.printStackTrace();
            return null;
        }
    }
}
